package com.analog.mserver.controller.user;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.analog.mserver.common.RestResult;
import com.analog.mserver.service.user.UserService;
import com.analog.mserver.vo.user.RoleVO;
import com.analog.mserver.vo.user.UserVO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 用户管理
 * @author simon
 * @create 2019年3月6日
 */
@RestController
@Api("UserController相关的api")
@RequestMapping("/user")
public class UserController {

	@Autowired
	private UserService userService;
	
	/**
	 * 用户分页
	 * @return
	 */
	@ApiOperation(value = "list", notes = "list")
	@PostMapping("/list")
	public RestResult page(UserVO vo){
		return new RestResult(userService.findUserPageList(vo));
	}
	
	@ApiOperation(value = "roleList", notes = "roleList")
	@PostMapping("/roleList")
	public RestResult roleList(RoleVO vo) {
		return new RestResult(userService.findRoleList(vo));
	}
	
	@ApiOperation(value = "rolesave", notes = "rolesave")
	@PostMapping("/role/save")
	public RestResult addRole(@RequestBody RoleVO vo) {
		return new RestResult(userService.saveRole(vo));
	}
	
}
